using System.Collections.Generic;
using TMPro;
using UnityEngine;

public class JumpCash : MonoBehaviour
{
	private List<GameObject> pool;

	[SerializeField]
	private GameObject jumpCash;

	private void Start()
	{
		pool = new List<GameObject>();
	}

	public void Spawn(Vector3 position, string cash)
	{
		GameObject gameObject = pool.Find((GameObject target) => !target.activeInHierarchy);
		if (gameObject != null)
		{
			gameObject.transform.position = position;
			gameObject.GetComponentInChildren<TextMeshPro>().text = cash;
			gameObject.SetActive(value: true);
		}
		else
		{
			gameObject = UnityEngine.Object.Instantiate(jumpCash, position, Quaternion.identity);
			gameObject.GetComponentInChildren<TextMeshPro>().text = cash;
			pool.Add(gameObject);
		}
	}
}
